home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / prog / basic / col2.c < prev    next >
C/C++ Source or Header  |  1994-08-05  |  486b  |  31 lines

  1.  
  2. // col2: filter for two-column output
  3.  
  4. #include <LEDA/list.h>
  5. #include <LEDA/stream.h>
  6.  
  7.  
  8. main()
  9. {
  10.   list<string> L;
  11.  
  12.   cmd_istream in("expand"); // expand tab's
  13.  
  14.   while (in)  L.append(read_line(in));
  15.  
  16.   if (L.length() % 2) L.Pop();
  17.  
  18.   list_item a = L[0];
  19.   list_item b = L[L.length()/2];
  20.  
  21.   while(b)
  22.   { int n = 38-L[a].length();
  23.     cout << L[a].head(38);
  24.     while (n-- > 0) cout << " ";
  25.     cout << "   " << L[b].head(38);
  26.     newline;
  27.     a = L.succ(a);
  28.     b = L.succ(b);
  29.    }
  30. }
  31.